package com.qianyitian.hope2.analyzer.controller;

import com.qianyitian.hope2.analyzer.service.DDUService;
import com.qianyitian.hope2.analyzer.service.RPSService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class DayDayUpController {
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    DDUService dduService;

    @GetMapping(value = "/ddu/stock")
    public String loadStockRPS() {
        return dduService.getAllStockDDU();
    }

    @GetMapping(value = "/ddu/fund")
    public String loadFundRPS() {
        return dduService.getAllFundDDU();
    }

    @GetMapping(value = "/ddu/refresh")
    @Scheduled(cron = "0 29 23 * * MON,TUE,WED,THU,FRI")
    public String refreshRPS() {
        int stock = dduService.refreshStockDDU();
        int fund = dduService.refreshFundDDU();
        return "stock:" + stock + "      fund:" + fund;
    }
}
